﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PMS.IRepository
{
    public interface IBaseRepository<T> where T : class, new()
    {
        #region 公共方法

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        int Add(T user);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        int Edit(T user);

        /// <summary>
        /// 获取最大的Id值
        /// </summary>
        /// <returns></returns>
        int GetMaxId();

        /// <summary>
        /// 获取单个实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T Dtl(int id);

        /// <summary>
        /// 判断是否存在
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        bool IsExists(int id);

        /// <summary>
        /// 删除单个实体
        /// </summary>
        /// <param name="id"></param>
        /// <param name="deleteBy">删除人UserId</param>
        /// <returns></returns>
        int Delete(int id, string deleteBy);

        /// <summary>
        /// 删除多个实体
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="deleteBy">删除人UserId</param>
        /// <returns></returns>
        int Delete(int[] ids, string deleteBy);

        /// <summary>
        /// 获取List
        /// </summary>
        /// <param name="sqlText">where条件</param>
        /// <returns></returns>
        List<T> GetList();

        List<T> GetList(Hashtable ht);

        int GetCount(Hashtable ht);

        /// <summary>
        /// 获取List
        /// </summary>
        /// <param name="sqlText">sql语句</param>
        /// <param name="param">参数/值 键值对(参数)</param>
        /// <returns></returns>
        List<T> GetList(string sqlText, Dictionary<string, object> param);


        /// <summary>
        /// 获取List
        /// </summary>
        /// <param name="sqlText">sql语句</param>
        /// <param name="param">参数/值 键值对(参数)</param>
        /// <param name="tran">是否开始事务</param>
        /// <returns></returns>
        List<T> GetList(string sqlText, Dictionary<string, object> param, IDbTransaction tran);

        void GetStrWhereAndParam(Hashtable ht, StringBuilder sb, Dictionary<string, object> param);

        /// <summary>
        /// 获取List
        /// </summary>
        /// <param name="sqlText">sql语句</param>
        /// <param name="param">参数/值 键值对(参数)</param>
        /// <param name="tran">是否开始事务</param>
        /// <param name="commandTime">执行时间</param>
        /// <returns></returns>
        List<T> GetList(string sqlText, Dictionary<string, object> param, IDbTransaction tran, int commandTime);

        /// <summary>
        /// 获取List
        /// </summary>
        /// <param name="sqlText">sql语句</param>
        /// <param name="param">参数/值 键值对(参数)</param>
        /// <param name="tran">是否开始事务</param>
        /// <param name="commandTime">执行时间</param>
        /// <param name="commandType">sqlText类型</param>
        /// <returns></returns>
        List<T> GetList(string sqlText, Dictionary<string, object> param, IDbTransaction tran, int commandTime,
            CommandType commandType);

        ///// <summary>
        ///// 获取List家排序
        ///// </summary>
        ///// <param name="sqlText">sql语句</param>
        ///// <param name="orderFiled">排序字段</param>
        ///// <param name="orderType">ASC 或者 DESC</param>
        ///// <returns></returns>
        //List<T> GetList( string orderFiled, string orderType);

        ///// <summary>
        ///// 获取List家排序
        ///// </summary>
        ///// <param name="sqlText">sql语句</param>
        ///// <param name="param">参数/值 键值对(参数)</param>
        ///// <param name="orderFiled">排序字段</param>
        ///// <param name="orderType">ASC 或者 DESC</param>
        ///// <returns></returns>
        //List<T> GetList( Dictionary<string, object> param, string orderFiled, string orderType);

        ///// <summary>
        ///// 获取List实体
        ///// </summary>
        ///// <param name="sqlText">sql语句</param>
        ///// <param name="orderFiled">排序字段</param>
        ///// <param name="orderType">ASC 或者 DESC</param>
        ///// <param name="pageIndex">第几页</param>
        ///// <param name="pageSize">每页多少航</param>
        ///// <param name="count">out参数 总条数</param>
        ///// <returns></returns>
        //List<T> GetList( string orderFiled, string orderType, int pageIndex, int pageSize,
        //    out int count);


        ///// <summary>
        ///// 获取List实体
        ///// </summary>
        ///// <param name="sqlText">sql语句</param>
        ///// <param name="param">参数/值 键值对(参数)</param>
        ///// <param name="orderFiled">排序字段</param>
        ///// <param name="orderType">ASC 或者 DESC</param>
        ///// <param name="pageIndex">第几页</param>
        ///// <param name="pageSize">每页多少航</param>
        ///// <param name="count">out参数 总条数</param>
        ///// <returns></returns>
        //List<T> GetList( Dictionary<string, object> param, string orderFiled, string orderType, int pageIndex, int pageSize,
        //    out int count);

        #endregion

        #region 扩展方法


        #endregion
    }
}
